Repository navigation
perf: implement lazy loading for heavy CLI commands (50% faster startup) - #151
Merged
jeremyeder merged 1 commit intoDec 4, 2025
Merged
Conversation
Improves CLI startup time by 50% (2.7s → 1.4s) by deferring imports of heavy dependencies (scipy, pandas, anthropic, github) until the commands that use them are actually invoked. **Implementation**: - Added LazyGroup class to defer command loading - Lazy-loaded commands: assess-batch, experiment, extract-skills, learn, submit - Lightweight commands loaded immediately: align, bootstrap, demo, repomix, research, schema **Performance Improvement**: - Before: agentready --help = 2.718s - After: agentready --help = 1.368s - Improvement: 50% faster (1.35s saved) **Why this matters**: - Most CLI invocations don't need scipy/pandas/anthropic - Users running 'agentready assess' or '--help' get instant response - Commands that need heavy libraries still load them when invoked **Testing**: - ✅ All commands tested and working - ✅ --help shows all commands (including lazy ones) - ✅ Lazy commands load correctly when invoked - ✅ No regression in functionality
commented
Dec 4, 2025
|
🎉 This PR is included in version 2.11.1 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Improves CLI startup time by 50% (2.7s → 1.4s) by implementing lazy loading for commands that import heavy dependencies.
Performance Improvement
agentready --helpagentready assessImplementation
Added
LazyGroupclass that defers importing command modules until they're actually invoked:Lazy-loaded commands: assess-batch, experiment, extract-skills, learn, submit
Immediately loaded commands: align, bootstrap, demo, repomix, research, schema
Why This Matters
assessor--helpget instant responseTechnical Approach
Used Click's extensible
Groupclass pattern (standard in Click ecosystem):LazyGroupthat overridesget_command()lazy_subcommandsdict (module_name, command_name)list_commands()includes lazy commands so--helpshows all available commandsTesting
agentready --help,experiment --help,assess-batch --help, etc.)--helpshows all commands (including lazy ones)Before/After Example
Before (all commands imported eagerly):
After (lazy loading):
Future Optimization Potential
If we wanted even faster startup (~0.5s target), we could:
But this 50% improvement addresses the main bottleneck (heavy scientific libraries).
Ready to merge: This is a low-risk refactoring with significant UX improvement and no breaking changes.
🤖 Generated with Claude Code